<template>
  <!-- 充值组件 -->
  <div class="add-money-box">
    <van-popup v-model="show">
      <h3>充值</h3>
      <div class="add-money">
        <p>充值金额：</p>
        <div class="input">
          <input type="number" placeholder="0" v-model="money" />
        </div>
        <span>元</span>
      </div>
      <!-- 按钮 -->
      <div class="btn" @click="addMoney(money)">充值</div>
    </van-popup>
  </div>
</template>

<script>
import { mapState, mapMutations } from "vuex";
export default {
  props: {
    // show: {
    //   type: Boolean,
    //   default: false,
    // },
    // money: {
    //   type: String,
    //   default: "",
    // },
  },
  // props: ["show", "money"],
  data() {
    return {};
  },
  methods: {
    addMoney(num) {
      this.$emit("getmoney", "");

      this.addMoney(num);
      this.$emit("getshow", false);
    },
    ...mapMutations({
      addMoney: "addMoney",
    }),
  },
  // 使用计算属性，
  computed: {
    // 直接解构数据状态
    ...mapState(["myMoney"]),
  },
};
</script>

<style lang="scss" >
// 充值
.add-money-box {
  h3 {
    text-align: center;
    font-size: 24px;
    height: 60px;
    line-height: 40px;
  }
  // 金额
  .add-money {
    width: 100%;
    height: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 20px;
    p {
      width: 100px;
    }
    .input {
      // width: 100px;
      flex: 1;
      padding-left: 2px;
      input {
        width: 90%;
        border-radius: 3px;
      }
    }
    span {
      width: 40px;
    }
  }
  // 按钮
  .btn {
    color: #fff;
    background-color: #39b5e7;
    width: 100px;
    height: 40px;
    line-height: 40px;
    margin: 30px auto 20px;
    border-radius: 5px;

    text-align: center;
    font-size: 22px;
  }
}
</style>

<style >
.add-money-box .van-popup--center {
  width: 250px;
  height: 200px;
  padding: 10px;
}
</style>